package com.supreme.commonboot.component;

import com.supreme.common.constant.ConsoleColors;
import com.supreme.common.utils.FilePathUtils;
import com.supreme.commonboot.annotation.ApplicationName;
import com.supreme.commonboot.condition.RunnerEventCondition;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;

@Component
@Conditional(value = {RunnerEventCondition.class})
public class BootApplicationRunner implements ApplicationRunner {

    @ApplicationName
    private String applicationName;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        ConsoleColors.printf(ConsoleColors.GREEN_BOLD_BRIGHT, "BootApplicationRunner = %s\n", applicationName);

        FilePathUtils.createDirectory(FilePathUtils.tempDataPath);
    }
}
